package com.sonic.jms.listeners;

import javax.jms.ExceptionListener;
import javax.jms.JMSException;

import ch.softwired.mobileibus.cmd.ISignalListener;

import com.sonic.log.ejb.impl.MQLogger;

public class MPapExceptionListener implements ExceptionListener {
	public static MQLogger logger       = new MQLogger(MPapExceptionListener.class, "MQ-PAP-LISTENER");
	
	public void onException(JMSException exception) {
		final String methodName = "onException";
    	final String errorCode = exception.getErrorCode();
		if(errorCode.compareToIgnoreCase(""+ISignalListener.SIG_ALIVE) == 0 ) {
			logger.debug(methodName, " --- [INFO] onException Listener: Established connection to Gateway");			
		} else if(errorCode.compareToIgnoreCase(""+ISignalListener.SIG_FAILURE) == 0 ) {
			logger.debug(methodName, " --- [INFO] onException Listener: Lost connection to Gateway");			
		} else {
			logger.debug(methodName, " --- [INFO] onException Listener, message: " + exception.getMessage() + " errorCode: " + exception.getErrorCode());
			logger.debug(methodName, " --- [INFO] onException Listener, exception: " + exception);
		}	    
    }
}
